<!DOCTYPE html>
<html>
	<head>
		<#include "/templates/commons/head.html">
		<script src="${ctx!}/scripts/app/document-page.js" type="text/javascript"></script>
		<style type="text/css">
			.layui-table-cell {
				height: auto;
			}
			.layui-table-cell .layui-form-checkbox {
				top: 0px;
			}
		</style>
		<script type="text/javascript">
			/**
			*点击查询按钮，查询用户列表
			*/
			function query(){
				document.opForm.action = "${ctx!}/DocumentController/getDocumentList.do";
				document.opForm.submit();
			}
			
			/**
			*点击进入子级列表
			*/
			function queryChildren(fileId) {
			    $("#paramParentId").val(fileId);
			    query();
			}
			
			/**
			*点击返回父级列表
			*/
			function backParent(parentId) {
			    $("#paramParentId").val(parentId);
			    query();
			}
			
			/**
			*  测试选择图片页面
			*  调用chooseDocument方法    参数1: 0单选  1多选   参数2: 回调函数，注意回调函数要有参数接收返回值   
			*/
			function chooseDialog() {
			    chooseDocument(1, "", function(res) {
					console.log(res);
			    })
			}
			
			/**
			*点击添加按钮进入添加页面
			*/
			function edit(id){
				document.opForm.action = "${ctx!}/DocumentController/edit.do?menuId="+id;
				document.opForm.submit();
			}
			
			/**
			*点击添加按钮进入添加页面
			*/
			function del(){
				if(seleBox("ids")){
				    layer.confirm("您是否确定要删除？", {
					    	btn: ['确定', '取消']
						}, function() {
						    document.opForm.action = "${ctx!}/DocumentController/del.do";
							document.opForm.submit();
						}, function() {
					});
				}
			}
		</script>
	</head>
	<body>
		<div id="div-body" class="body">
			<form id="opForm" name="opForm" method="post">
				<!-- 隐藏传值input -->
				<input type="hidden" id="paramParentId" name="param_parentId" value="${Request.param_parentId!}"/>
				<!-- 隐藏传值input -->
				<div class="search-head">
			        <!-- 顶部搜索&按钮栏 Start -->
			        <blockquote class="layui-elem-quote">
						<!-- 头部右边搜索条件 Start -->
			            <div class="layui-form layui-list-btn-group">
		                	<!-- 关键字搜索 Start -->
		                	<div class="input-block">
			                	<label class="layui-form-label">关键字</label>
			                    <div class="layui-input-inline">
			                        <input type="text" name="param_fileName" autocomplete="off" class="layui-input" placeholder="请输入文件名称" value="${Request.param_fileName!}"/>
			                    </div>
		                	</div>
		                	<!-- 关键字搜索 End -->
			            </div>
			            <!-- 头部右边搜索条件 End -->
					</blockquote>
		        	<!-- 按钮 Start -->
			        <blockquote class="layui-elem-quote list-btn-group">
						<div class="layui-btn-group">
							<#if Session.CUR_MENU.addRole == 1>
								<button class="layui-btn" type="button" onclick="DocumentPage.addFolder('${Request.param_parentId!}');"><i class="layui-icon">&#xe654;</i>创建文件夹</button>
							</#if>
							<#if (Session.CUR_MENU.addRole == 1 && Request.param_parentId != '0')>
								<button class="layui-btn" type="button" onclick="DocumentPage.editFile('${Request.param_parentId!}', '');"><i class="layui-icon">&#xe654;</i>上传文件</button>
							</#if>
							<#if Session.CUR_MENU.deleteRole == 1>
								<button class="layui-btn" type="button" onclick="del();"><i class="layui-icon">&#xe640;</i>删除</button>
							</#if>
							<#if Session.CUR_MENU.deleteRole == 1>
								<input type="button" class="layui-btn" onclick="chooseDialog(1);" value="测试弹窗">
							</#if>
						</div>
						<#if Session.CUR_MENU.selectRole == 1>
							<button class="layui-btn query-btn layui-btn-danger" type="button" onclick="query();"><i class="layui-icon">&#xe615;</i>查询</button>
						</#if>
			        </blockquote>
					<!-- 按钮 End -->
			        <!-- 顶部搜索&按钮栏End -->
		        </div>
		        <!-- 顶部搜索&按钮栏 End -->
		        <div id="container">
		        	<!-- message Start -->
		        	<div id="div-message">${message!}</div>
		        	<!-- message End -->
		        	<!-- table list Start -->
		        	<div class="data-grid-group">
		        		<table lay-filter="data-grid" class="layui-table dymanic-table">
		        			<thead>
		        				<tr>
									<th lay-data="{field:'ids', checkbox: true}"></th>
									<th lay-data="{field:'pathShow', algin: 'center'}">缩略图</th>
									<th lay-data="{field:'fileName', algin: 'center', sort:true}">文件名</th>
									<th lay-data="{field:'fileSize', algin: 'center', sort:true}">文件大小</th>
									<th lay-data="{field:'fileType', algin: 'center', sort:true}">文件类型</th>
									<th lay-data="{field:'createBy', algin: 'center', sort:true}">创建人</th>
									<th lay-data="{field:'createDate', algin: 'center', sort:true}">创建时间</th>
									<th lay-data="{field:'updateBy', algin: 'center', sort:true}">修改人</th>
									<th lay-data="{field:'updateDate', algin: 'center', sort:true}">修改时间</th>
								</tr>
		        			</thead>
		        			<tbody>
		        				<#if Request.param_parentId != '0'>
									<tr>
										<td align="center"><img src="${ctx!}/images/main/backup.png" width="20px" height="20px" /></td>
										<td colspan="8" style="padding-left: 20px;">
											<a href="javascript:void(0);" onclick="backParent('${parent.parentId!}')">${parent.fileName!}/</a>
											<span style="color: #B9B4B6;">(返回上一级)</span>
										</td>
									</tr>
								</#if>
								<#if list??>
									<#list list as DocumentBean>
										<tr>
											<td>
												<input name="ids" lay-skin="primary" type="checkbox" value="${DocumentBean.fileId!}"/>
											</td>
											<td>
												<#if DocumentBean.fileType == 'folder'>
													<i class="layui-icon">&#xe61d;</i>
												<#else>
													<img src="${DocumentBean.pathShow!}" alt="" width="100px" height="80px"/>
												</#if>
											</td>
											<td>
												<#if DocumentBean.fileType == 'folder'>
													<a href="javascript:void(0);" onclick="queryChildren('${DocumentBean.fileId!}')">
														${DocumentBean.fileName!'-'}
													</a>
												<#else>
													<a href="javascript:void(0);" onclick="DocumentPage.editFile('${DocumentBean.parentId!}', '${DocumentBean.fileId!}')">
														${DocumentBean.fileName!'-'}
													</a>
												</#if>
											</td>
											<td>
												<#if DocumentBean.fileType == 'folder'>
													-
												<#else>
													${DocumentBean.fileSize!'-'}
												</#if>
											</td>
											<td>${DocumentBean.fileType!'-'}</td>
											<td>${DocumentBean.createBy!'-'}</td>
											<td>${DocumentBean.createDate!'-'}</td>
											<td>${DocumentBean.updateBy!'-'}</td>
											<td>${DocumentBean.updateDate!'-'}</td>
										</tr>
									</#list>
								</#if>
		        			</tbody>
		        		</table>
		        		<!-- 分页 Start -->
						<div class="page-helper">
							<#include "/templates/commons/page.html">
						</div>
						<!-- 分页 End -->
		        	</div>
		        	<!-- table list End -->
		        </div>
		        <!-- table list group End -->
			</form>
		</div>
	</body>
</html>